package com.dbtest;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.beans.dbtest.BomBean;
import com.register.beans.RegisterBean;

public class MyBatisTest {

	public static void main(String[] args) {
		SqlSession session = SqlMapClient.getSqlSession();
		BomBean bom = session.selectOne("mybatis.getOne", "1001");
		System.out.println("하나 뽑기 : " + bom.getItem_Id());

		List<BomBean> list = session.selectList("mybatis.getUser");

		System.out.println("list.size : " + list.size());
		System.out.println("여러개 뽑기 : ");
		for (BomBean u : list){
			System.out.print(u.getItem_Id() + "\t");
			System.out.println(u.getItem_Name());
		}

		System.out.println();
		RegisterBean bean = new RegisterBean();
		bean.setId("eee");
		bean.setPassWd("111");
		List<RegisterBean> rList = session.selectList("mybatis.SEARCH_MEMBER_SQL", bean);
		System.out.println("RegisterBean : ");
		for(RegisterBean r : rList){
			System.out.print(r.getName() + "\t");
			System.out.print(r.getId() + "\t");
			System.out.print(r.getPassWd() + "\t");
			System.out.print(r.getEmail() + "\t");
			System.out.print(r.getSex() + "\t");
			System.out.print(r.getBirthDate() + "\t");
			System.out.print(r.getCellPhone() + "\t");
			System.out.println(r.getImgPath());
		}
		
		System.out.println();
		List<RegisterBean> allList = session.selectList("mybatis.SEARCH_ALL_MEMBERS_SQL");
		System.out.println("RegisterBean All : ");
		System.out.println("allList.size : " + allList.size());
		for(RegisterBean all : allList){
			System.out.print(all.getName() + "\t");
			System.out.print(all.getId() + "\t");
			System.out.print(all.getPassWd() + "\t");
			System.out.print(all.getEmail() + "\t");
			System.out.print(all.getSex() + "\t");
			System.out.print(all.getBirthDate() + "\t");
			System.out.print(all.getCellPhone() + "\t");
			System.out.println(all.getImgPath());
		}
		
		session.close();
	}
}